package com.example.anpapi.entity.po.novelmodel.Chapter;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum ChapterStatus {
    DRAFT("DRAFT", "草稿"),
    PUBLISHED("PUBLISHED", "已发布"),
    SCHEDULED("SCHEDULED", "定时发布");

    @EnumValue
    private final String code;

    @JsonValue
    private final String description;

    ChapterStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据code获取枚举
     */
    public static ChapterStatus getByCode(String code) {
        for (ChapterStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return DRAFT;
    }

    @Override
    public String toString() {
        return this.code;
    }
}

